package com.sskj.fca.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.fca.http.HttpConfig;
import com.sskj.fca.ui.activity.ApplyAgentActivity;

import java.io.File;

/**
 * Created by Q-Kang on 2019/1/21.
 */

public class ApplyAgentPresenter extends BasePresenter<ApplyAgentActivity> {

    public void uploadImg(File file) {
        httpService.uploadImg(file)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updatePath((String) httpData.getData());
                        }
                    }
                });
    }

    public void applyAgent(String name, String mobile, String card1, String card2) {
        httpService.applyAgent(name, mobile, card1, card2)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.finish();
                        }
                    }
                });
    }

}
